package com.enfi.api.modules.ext.mq.consumer;

import com.enfi.api.modules.ext.mq.config.RabbitMqConfiguration;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * direct 模式 消费者
 * @author xukk
 * @date 2020/3/9
 */
@Component
@Slf4j
public class DirectConsumer {

    /**
     * 消息消息 重试失败 进入死信环节
     * @param channel 通道
     * @param message 消息
     */
    @RabbitListener(queues = RabbitMqConfiguration.DEAD_QUEUE,concurrency = "5")
    public void consumerDeadQueue(Channel channel, Message message){
        log.warn("【deadQueue 监听到消息】进入死信队列");
        String json= new String(message.getBody());
        log.warn("死信 内容:{}",json);
        log.warn("【deadQueue 监听到消息】处理成功");
    }



}